<?php
include_once('common/header.php');	
if($AppUI->id <= 0 || !isset($_SERVER['HTTP_REFERER'])) {	
	$arrJson = array('error'=>1,'msg'=>$arrError[1]);
	echo $objRequest->getParam('callback') . '(' . Zend_Json::encode($arrJson) . ')';
	exit();
}
$intError		= 0;
$strMessage		= '';
$strData		= '';
$strProductName	= '';
$strRefer		= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$intFgiftId		= $objRequest->getParam('fgiftid',0);
$intTargetId	= Vfriend_Function::base64D($objRequest->getParam('uid',''));
$strToken		= $objRequest->getParam('token','');
$strSession		= Vfriend_Function::getSecret($intFgiftId, SE_FULLHOUSE_GIFT_DENY);
if($intFgiftId && $intTargetId && $strToken != '' && $strSession != '' && $strSession == $strToken && Vfriend_Function::isValidLink($strRefer)) {
	Vfriend_Function::deleteSecret($intFgiftId, SE_FULLHOUSE_GIFT_DENY);	
	$objVfriendUser	= new Vfriend_User();
	$objURequest	= new URequest();
	$arrResult		= $objURequest->denyGift($AppUI->id, $intTargetId, $intFgiftId, $intError);	
	$objTarget		= $objVfriendUser->getInfo($intTargetId);	
	if($intError == 0) {
		$strProductName	= isset($arrResult['name']) ? $arrResult['name'] : '';
		$objURequest->deleteRequestByRefObjId($intFgiftId,$AppUI->id, $intTargetId,1);		
		$strMessage		= $arrMessage[29];
		$strMessage		= str_replace('[strProductName]', $strProductName, $strMessage);
		$strMessage		= str_replace('[strFullName]', $objTarget->fullnamevn, $strMessage);
	} else {
		$intError	= 38;
	}
	$intUserProId 	= $AppUI->id;
	include_once('fullhouse/box-gift.php');	
	$objView 		= Zend_Registry::get('objView');
	$strData		= $objView->fetch('fullhouse/box-gift.tpl');
	
}else {
	$intError	= 27;
}
if($intError > 0) {
	$strMessage	= $arrError[$intError];	
}
$arrJson = array('error'=>$intError,'msg'=>$strMessage,'data'=>$strData);
echo $objRequest->getParam('callback') . '(' . Zend_Json::encode($arrJson) . ')';
exit();
?>